package com.example.eschool.fragment;

import android.content.Intent;
import android.os.Bundle;

import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;

import com.example.eschool.SonActivity;
import com.example.eschool.R;


public class PersonFragment extends Fragment implements View.OnClickListener{
    View rootview;
    LinearLayout invest,record,question,setting;
    RelativeLayout person_setting;
     public PersonFragment() {

    }


    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
      }

    @Override
    public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
        super.onViewCreated(view, savedInstanceState);
        initView();


    }

    private void initView() {
        invest = rootview.findViewById(R.id.invest);
        invest.setOnClickListener(this);

        person_setting = rootview.findViewById(R.id.person_setting);
        person_setting.setOnClickListener(this);

        record = rootview.findViewById(R.id.record);
        record.setOnClickListener(this);

        question = rootview.findViewById(R.id.question);
        question.setOnClickListener(this);

        setting = rootview.findViewById(R.id.setting);
        setting.setOnClickListener(this);
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        if (rootview == null){
            rootview=inflater.inflate(R.layout.fragment_person, container, false);
        }

        return rootview;
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()){
            case R.id.invest:
                Intent intent = new Intent(getActivity(), SonActivity.class);
                intent.putExtra("fragment", "invest");
                intent.putExtra("title", "充值");
                startActivity(intent);
                break;

            case R.id.person_setting:
                Intent intent1 = new Intent(getActivity(), SonActivity.class);
                intent1.putExtra("fragment", "person_setting");
                intent1.putExtra("title", "个人设置");
                startActivity(intent1);
                break;

            case R.id.record:
                Intent intent2 = new Intent(getActivity(), SonActivity.class);
                intent2.putExtra("fragment", "record");
                intent2.putExtra("title", "记录");
                startActivity(intent2);
                break;

            case R.id.question:
                Intent intent3 = new Intent(getActivity(), SonActivity.class);
                intent3.putExtra("fragment", "question");
                intent3.putExtra("title", "常见问题");
                startActivity(intent3);
                break;

            case R.id.setting:
                Intent intent4 = new Intent(getActivity(), SonActivity.class);
                intent4.putExtra("fragment", "setting");
                intent4.putExtra("title", "系统设置");
                startActivity(intent4);
                break;
        }
    }


}